package com.cz.influxdb.test;

import com.cz.influxdb.config.InfluxDBHelper;
import com.influxdb.client.DeleteApi;
import com.influxdb.client.InfluxDBClient;

import java.time.OffsetDateTime;

public class DeleteWeather {
    public static void main(String[] args) {
        InfluxDBHelper helper = new InfluxDBHelper();
        InfluxDBClient client = helper.getInfluxDBClient();

        DeleteApi deleteApi = client.getDeleteApi();

        OffsetDateTime start = OffsetDateTime.parse("1800-01-01T00:00:00Z");  // 开始时间
        OffsetDateTime stop = OffsetDateTime.parse("2026-01-01T00:00:00Z");   // 结束时间

        // 指定删除条件，必须至少指定 measurement
        String predicate = "_measurement=\"weather\"";
        deleteApi.delete(start, stop,predicate,"root","root");
        client.close();
    }
}
